//
//  GeneralAuditTabSection.swift
//  ANOASTORE
//
//  Created by hudan on 2025/7/30.
//  Copyright © 2025 zwb. All rights reserved.
//

import Foundation

final class GeneralAuditTabSection: UIView {
    var titles = [String]() {
        didSet {
            var tmpTabTitles = [SegmenttData]()
            
            for (_, title) in titles.enumerated() {
                tmpTabTitles.append(SegmenttData(id: "", nm: title))
            }
            
            self.tabSectionHeader.setCollecDataSource(arr: tmpTabTitles)
        }
    }
    
    var selectBlock: ((Int) -> Void)?
    
    private lazy var tabSectionHeader: KSZoneItem = {
        let appe = KSFormHAppear().roundType(.top)
        let view = KSZoneItem(appearance:appe)
        view.zoneSegV.zShowType = .left
        view.collecSelected = { [weak self] index, sdata in
            self?.selectBlock?(index)
        }
        return view
    }()
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        initUI()
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    private func initUI() {
        
        extBgColor(color: .clear)
        
        addSubview(tabSectionHeader)
        tabSectionHeader.snp.makeConstraints { make in
            make.left.equalToSuperview().offset(6)
            make.right.equalToSuperview().offset(-6)
            make.top.equalToSuperview().offset(10)
            make.bottom.equalToSuperview()
        }
    }
}
